package hotel.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import hotel.service.IHotelPicService;
import common.dao.HotelPicDAO;
import common.pojo.HotelPic;



@Scope("prototype")
@Service
public class HotelPicService  implements IHotelPicService{

	@Resource
	private HotelPicDAO hotelPicDAO;
	

	public List<HotelPic> find(String where,int start, int limit,String orderbys) {
		return hotelPicDAO.findList(where,start, limit, orderbys);
	}
	
	public List<HotelPic> find() {
		return hotelPicDAO.findList();
	}
	
	public int getCount(String where){
		return hotelPicDAO.getCount(where);
	}

	public boolean save(HotelPic hotelPic) {
		hotelPicDAO.save(hotelPic);
		return true;
	}
	
	public HotelPic find(int id){
		return hotelPicDAO.findInfoById(id);
	}

	public boolean update(HotelPic hotelPic) {
		return hotelPicDAO.update(hotelPic);
	}

	public boolean delete(String ids) {
		String[] id = StringUtils.split(ids, ",");
		for(int i=0;i<id.length;i++){
			hotelPicDAO.delete(Integer.valueOf(id[i]));
		}
		return true;
	}
	
	public boolean update(String[] ids,String[] sorts){
    	for(int i=0;i<ids.length;i++)
    	{
    		hotelPicDAO.update("update hotelPic set sort="+sorts[i]+" where id="+ids[i]);
    	}
    	return true;
    }
}
